
function req(url, data, cb, method, isLoading) {

  for (var Key in data) {
    if (data[Key] === null) {
      delete data[Key];
    }

  }
  if (isLoading){
    tt.showLoading({
      title: '加载中...',
    })
  }
  tt.request({
    url: url,
    data: data,
    method: method || 'GET',
    header: {
      "content-type": "application/x-www-form-urlencoded"
    },
    success: function(res) {
      if (isLoading) {
        wx.hideLoading()
      }
      return typeof cb == "function" && cb(res.data)
    },
    fail: function() {
      wx.hideLoading()
      return typeof cb == "function" && cb(false)
    }
  })
}

function reqCommon(url, data, cb, method) {
  req(url, data, cb,method,true);
}

function reqNoLoading(url, data, cb, method) {
  req(url, data, cb, method || 'GET' , false);
}
module.exports = {
  req: req,
  reqCommon: reqCommon,
  reqNoLoading: reqNoLoading
}